package com.jdemo.feature.thread;

/**
 * TicketTest
 *
 * @author longlin(longlin@cyou-inc.com)
 * @date 2014/8/25
 * @since V1.0
 */
public class TicketTest implements Runnable{
    private int ticket = 10;

    public void run() {
        for(int i =0;i<500;i++){
            if(this.ticket>0){
                System.out.println(Thread.currentThread().getName()+"卖票---->"+(this.ticket--));
            }
        }
    }

    public static void main(String[] args) {
        TicketTest ticketTest = new TicketTest();
        new Thread(ticketTest,"线程1").start();
        new Thread(ticketTest,"线程2").start();
        new Thread(ticketTest,"线程3").start();
    }
}
